<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('修改部门')" />
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-dept-edit" th:object="${dept}">
			<input name="id" type="hidden" th:field="*{id}" />
			<input id="parentId" name="parentId" type="hidden" th:field="*{parentId}" />

			<div class="form-group">
				<label class="col-sm-3 control-label">上级部门：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" id="treeName" readonly="true" th:field="*{parentName}">

				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">部门名称：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="deptName" th:field="*{orgName}" id="deptName" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">负责人：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="leader" th:field="*{leader}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">联系电话：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="phone" th:field="*{phone}">
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">部门状态：</label>
				<div class="col-sm-8">
					<select class="form-control" name="status" >
						<option value="1" th:selected="${dept.status == 1 ? true : false}" >开启</option>
						<option value="2" th:selected="${dept.status == 2 ? true : false}" >关闭</option>
					</select>
				</div>
			</div>
		</form>
	</div>
	<th:block th:include="include :: footer" />
	<script type="text/javascript">
		var prefix = ctx + "sys/org";

		$("#form-dept-edit").validate({
			onkeyup: false,
			rules:{
				orgName:{
					required:true,
					minlength:2,
					maxlength:30
				},
				phone:{
					isPhone:true
				},
			},
			messages: {
				orgName: {
					required:"请输入部门名称",
					minlength:"最少两个长度",
					maxlength:"最多30个长度"
				}
			},
			focusCleanup: true
		});
		

		function submitHandler() {
	        if ($.validate.form()) {
	        	$.operate.save(prefix + "/updateById", $('#form-dept-edit').serializeJson(),null,true);
	        }
	    }
	

	</script>
</body>
</html>
